package com.easyedu.dean.controller;

import com.easyedu.core.entity.po.CultivationScheme;
import com.easyedu.core.util.R;
import com.easyedu.dean.entity.dto.request.ReqCultivationScheme;
import com.easyedu.dean.entity.dto.response.RespQueryCultivationSchemeList;
import com.easyedu.dean.service.CultivationSchemeService;
import java.util.List;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author lmr</br>
 * 培养计划管理
 **/
@RestController
@RequestMapping("/dean")
public class CultivationSchemeController {

    private final CultivationSchemeService cultivationSchemeService;

    public CultivationSchemeController(CultivationSchemeService cultivationSchemeService) {
        this.cultivationSchemeService = cultivationSchemeService;
    }

    /**
     * 功能描述: 创建培养方案
     *
     * @param schemeQuery 1 培养方案创建数据
     * @return : com.easyedu.api.util.R
     **/
    @PostMapping("/cultivation")
    public R createCultivationScheme(@RequestBody @Valid ReqCultivationScheme schemeQuery) {
        cultivationSchemeService.createCultivationScheme(schemeQuery);
        return R.ok().message("新增培养方案成功");
    }

    /**
     * 功能描述: 根据年级,获取查询培养方案序号以及所属学院</br>
     *
     * @param grade 1 年级
     * @return
     */
    @GetMapping("/cultivation")
    public R getCultivationScheme(@RequestParam String grade) {
        List<RespQueryCultivationSchemeList> cultivationSchemeLists = cultivationSchemeService.getCultivationScheme(grade);
        return R.ok().data(cultivationSchemeLists);
    }

    /**
     * 功能描述: 根据培养方案序号,获取培养计划
     *
     * @param cultivationNumber 1 培养方案序号
     * @return
     */
    @GetMapping("/cultivation/course")
    public R getCultivationSchemeCourse(@RequestParam String cultivationNumber) {
        List<CultivationScheme> cultivationSchemeCourse =
                cultivationSchemeService.getCultivationSchemeCourse(cultivationNumber);
        return R.ok().data(cultivationSchemeCourse);
    }
}
